//package com.acegear.horizon.config;
//
//import org.springframework.amqp.core.TopicExchange;
//import org.springframework.amqp.rabbit.annotation.EnableRabbit;
//import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
//import org.springframework.amqp.rabbit.connection.ConnectionFactory;
//import org.springframework.amqp.rabbit.core.RabbitTemplate;
//import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
//import org.springframework.amqp.support.converter.MessageConverter;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//
///**
// * Created by wangsike on 2016/12/12.
// */
//@Configuration
//@EnableRabbit
//public class RabbitMQConfig {
//
//    @Value("${horizon.domain.rabbit.exchange}")
//    private String exchange;
//
//    @Bean
//    @Primary
//    public TopicExchange topicExchange() {
//        return new TopicExchange(exchange);
//    }
//
//    @Bean
//    public MessageConverter jsonMessageConverter() {
//        return new Jackson2JsonMessageConverter();
//    }
//
//    @Bean
//    public RabbitTemplate rabbitTemplate(ConnectionFactory cf, MessageConverter mc) {
//        RabbitTemplate rabbitTemplate = new RabbitTemplate(cf);
//        rabbitTemplate.setMessageConverter(mc);
//        rabbitTemplate.setExchange(exchange);
//        return rabbitTemplate;
//    }
//
//    @Bean
//    public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory(ConnectionFactory cf, MessageConverter mc) {
//        SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
//        factory.setConnectionFactory(cf);
//        factory.setMessageConverter(mc);
//        return factory;
//    }
//}
